# The name of our project is "PR". CMakeLists files in this project can 
# refer to the root source directory of the project as ${PR_SOURCE_DIR} 
cmake_minimum_required (VERSION 2.8 FATAL_ERROR) 
project( PA )
# use solution folders
OPTION(BUILD_USE_SOLUTION_FOLDERS "Enable grouping of projects in VS" OFF)
# fast build
OPTION(BUILD_FAST "Disable CMake dependency checking" OFF)
IF(BUILD_FAST)
MESSAGE(WARNING "Dependency checking is disabled!")
INCLUDE_REGULAR_EXPRESSION("^$")
ENDIF(BUILD_FAST)

if(COMMAND cmake_policy)
  cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)

#Use solution folders acc. to setting
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ${BUILD_USE_SOLUTION_FOLDERS}) 

OPTION(TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" ON)
# keep the source base clean and stable
if(MSVC)
IF(TREAT_WARNINGS_AS_ERRORS)
SET(WARNING_ERROR "/WX")
ENDIF(TREAT_WARNINGS_AS_ERRORS)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_ERROR}")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_ERROR}")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${WARNING_ERROR}")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${WARNING_ERROR}")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${WARNING_ERROR}")
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${WARNING_ERROR}")
endif(MSVC)

if(WIN32)
	add_definitions(-D_USE_MATH_DEFINES)
  
  foreach(config_var ${CMAKE_CONFIGURATION_TYPES})
    string(TOUPPER "${config_var}" config_var_upper)
    foreach(flag_var
        CMAKE_C_FLAGS_${config_var_upper}
        CMAKE_CXX_FLAGS_${config_var_upper})

      if(${flag_var} MATCHES "/MD")
        string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
      endif(${flag_var} MATCHES "/MD")

    endforeach(flag_var)
  endforeach(config_var)
  
endif(WIN32)

SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/built_components)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/built_components)

if(WIN32)
ADD_DEFINITIONS(-DBOOST_ALL_NO_LIB)
endif(WIN32)

#SET(INSTALL_PATH ${CMAKE_CURRENT_BINARY_DIR}/../bin)

#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/common)

subdirs(common/external/boost_cmake)
subdirs(common/external/bullet)
subdirs(portal_adaptation)

